vim.g.mapleader = " "
vim.keymap.set("v", "p", "pgvy", { desc = "Paste", noremap = true, silent = true })
vim.keymap.set("v", "P", "Pgvy", { desc = "Paste", noremap = true, silent = true })

vim.keymap.set("n", "gt", ":bnext<CR>", { desc = "Next Buffer", noremap = true, silent = true })
vim.keymap.set("n", "gT", ":bprevious<CR>", { desc = "Prev Buffer", noremap = true, silent = true })
vim.keymap.set("n", "<leader>bn", ":bnext<CR>", { desc = "Next Buffer", noremap = true, silent = true })
vim.keymap.set("n", "<leader>bf", ":bprevious<CR>", { desc = "Prev Buffer", noremap = true, silent = true })

vim.keymap.set("n", "<A-k>", "<cmd>m .-2<cr>==", { desc = "Move up", noremap = true, silent = true })
vim.keymap.set("n", "<A-j>", "<cmd>m .+1<cr>==", { desc = "Move down", noremap = true, silent = true })
vim.keymap.set("i", "<A-k>", "<esc><cmd>m .-2<cr>==gi", { desc = "Move up", noremap = true, silent = true })
vim.keymap.set("i", "<A-j>", "<esc><cmd>m .+1<cr>==gi", { desc = "Move down", noremap = true, silent = true })
vim.keymap.set("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move up", noremap = true, silent = true })
vim.keymap.set("v", "<A-j>", ":m '>+1<cr>gv=gv", { desc = "Move down", noremap = true, silent = true })

vim.keymap.set("n", "<leader>u%", function()
	vim.fn.setreg("+", vim.fn.expand("%:t:r"))
end, { desc = "File Name To Register +", noremap = true, silent = true })
vim.cmd([[cnoremap <C-a> <Home>]])
vim.cmd([[cnoremap <C-e> <End>]])
vim.cmd([[cnoremap <C-f> <Right>]])
vim.cmd([[cnoremap <C-b> <Left>]])
vim.cmd([[cnoremap <C-k> <C-p>]])
vim.cmd([[cnoremap <C-j> <C-n>]])
vim.cmd([[cnoremap <C-o> <C-f>]])
vim.cmd([[cnoremap <C-d> <Del>]])

vim.cmd([[inoremap <C-a> <Home>]])
vim.cmd([[inoremap <C-e> <End>]])
vim.cmd([[inoremap <C-f> <Right>]])
vim.cmd([[inoremap <C-b> <Left>]])
vim.cmd([[imap <C-k> <C-p>]])
vim.cmd([[imap <C-j> <C-n>]])
vim.cmd([[inoremap <C-d> <Del>]])

vim.keymap.set("n", "<leader>ee", ":edit $MYVIMRC<CR>", { silent = true, noremap = true })
vim.keymap.set("n", "<leader>ss", ":source $MYVIMRC<CR>", { silent = true, noremap = true })
vim.keymap.set("i", "jk", "<esc>", { silent = true, noremap = true })

vim.keymap.set("n", "<C-h>", "<C-w>h", { noremap = true, silent = true })
vim.keymap.set("n", "<C-l>", "<C-w>l", { noremap = true, silent = true })
vim.keymap.set("n", "<C-j>", "<C-w>j", { noremap = true, silent = true })
vim.keymap.set("n", "<C-k>", "<C-w>k", { noremap = true, silent = true })
